package org.dmcs.homework.statistics.implementations;

import org.dmcs.homework.statistics.api.ICombinationsGenerator;
import org.dmcs.homework.statistics.api.ICovarianceCalculator;
import org.dmcs.homework.statistics.api.IFeatureSetSelector;
import org.dmcs.homework.statistics.api.IFischerCoefficientCalculator;
import org.dmcs.homework.statistics.api.IMeanCalculator;

/**
 * "Static Factory" performing DI and providing the user with a fully configured feature set selector.
 * @author Zielony
 * @version 1.0
 */
public class FeatureSetSelectorFactory {
	/**
	 * Creates a fully-configured <code>IFeatureSetSelector</code>.
	 * @return the requested feature set selector.
	 */
	public static IFeatureSetSelector getFeatureSetSelector() {
		/*
		 * Narzedzie do obliczania srednich.
		 */
		IMeanCalculator meanCalculator = new MeanCalculator();
		
		/*
		 * Narzedzie do obliczania kowariancji.
		 */
		ICovarianceCalculator covarianceCalculator = new CovarianceCalculator(meanCalculator);
		
		/*
		 * Narzedzie do obliczania wspolczynnikow Fischera.
		 */
		IFischerCoefficientCalculator fischerCalculator = new FischerCoefficientCalculator(meanCalculator, 
				covarianceCalculator, new VectorUtil());
		
		/*
		 * Generator kombinacji.
		 */
		ICombinationsGenerator combinationsGenerator = new CombinationsGenerator();
		
		/*
		 * Narzedzie do wyboru optymalnego zbioru wymiarow do grupowania danych.
		 */
		FeatureSetSelector featureSetSelector = new FeatureSetSelector((1000*60),
				fischerCalculator, combinationsGenerator);
		
		return featureSetSelector;
	}
	
	public static IFischerCoefficientCalculator getFischerCoefficientCalculator() {
		/*
		 * Narzedzie do obliczania srednich.
		 */
		IMeanCalculator meanCalculator = new MeanCalculator();
		
		/*
		 * Narzedzie do obliczania kowariancji.
		 */
		ICovarianceCalculator covarianceCalculator = new CovarianceCalculator(meanCalculator);
		
		/*
		 * Narzedzie do obliczania wspolczynnikow Fischera.
		 */
		IFischerCoefficientCalculator fischerCalculator = new FischerCoefficientCalculator(meanCalculator, 
				covarianceCalculator, new VectorUtil());
		
		return fischerCalculator;
	}
}